home *** CD-ROM | disk | FTP | other *** search
/ PC Graphics Unleashed / PC Graphics Unleashed.iso / ch01 / match.doc < prev    next >
Text File  |  1993-01-10  |  3KB  |  59 lines

  1.  
  2.                     REGEX Globber (Wild Card Matching)
  3.  
  4.                A *IX SH style pattern matcher written in C
  5.                    V1.10 Dedicated to the Public Domain
  6.  
  7.                                 March  12, 1991
  8.                                  J. Kercheval
  9.                          [72450,3702] -- johnk@wrq.com
  10.  
  11.  
  12.  
  13.  
  14. *IX SH style Regular Expressions
  15. ================================ 
  16.  
  17. The *IX command SH is a working shell similar in feel to the MSDOS
  18. shell COMMAND.COM.  In point of fact much of what we see in our
  19. familiar DOS PROMPT was gleaned from the early UNIX shells available
  20. for many of machines the people involved in the computing arena had
  21. at the time of the development of DOS and it's much maligned
  22. precursor CP/M (although the UNIX shells were and are much more
  23. flexible and powerful then those on the current flock of micro
  24. machines).  The designers of DOS and CP/M did some fairly strange
  25. things with their command processor and OS.  One of those things was
  26. to only selectively adopt the regular expressions allowed within the
  27. *IX shells.  Only '?' and '*' were allowed in filenames and even with
  28. these the '*' was allowed only at the end of a pattern and in fact
  29. when used to specify the filename the '*' did not apply to extension.
  30. This gave rise to the all too common expression "*.*".
  31.  
  32. REGEX Globber is a SH pattern matcher.  This allows such
  33. specifications as *75.zip or * (equivelant to *.* in DOS lingo).
  34. Expressions such as [a-e]*t would fit the name "apple.crt" or
  35. "catspaw.bat" or "elegant".  This allows considerably wider
  36. flexibility in file specification, general parsing or any other
  37. circumstance in which this type of pattern matching is wanted. 
  38.  
  39. A match would mean that the entire string TEXT is used up in matching
  40. the PATTERN and conversely the matched TEXT uses up the entire
  41. PATTERN. 
  42.  
  43. In the specified pattern string:
  44.      `*' matches any sequence of characters (zero or more)
  45.      `?' matches any character
  46.      `\' suppresses syntactic significance of a special character
  47.      [SET] matches any character in the specified set,
  48.      [!SET] or [^SET] matches any character not in the specified set.
  49.  
  50. A set is composed of characters or ranges; a range looks like
  51. 'character hyphen character' (as in 0-9 or A-Z).  [0-9a-zA-Z_] is the
  52. minimal set of characters allowed in the [..] pattern construct.
  53. Other characters are allowed (ie. 8 bit characters) if your system
  54. will support them (it almost certainly will).
  55.  
  56. To suppress the special syntactic significance of any of `[]*?!^-\',
  57. and match the character exactly, precede it with a `\'.
  58.  
  59.